package crudfx.container;
import crudfx.interop.*;
import java.awt.*;
import javax.swing.*;
import crudfx.data.*;
import javax.swing.BorderFactory;
import javax.swing.border.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class Sizer extends UIComponent {
    var panel:JamTop;
    public var width:Number=0 on replace {setSize();};
    public var height:Number=0 on replace {setSize();};
    public var content:UIComponent;
    function setSize(){
        if(panel==null)return;
        var w:Number=width;
        var h:Number=height;
        if(w<1 or w>12345)w=8;
        if(h<1 or h>12345)h=8;
        panel.getJComponent().setPreferredSize(new java.awt.Dimension(w,h));
        panel.getJComponent().validate();
        }
    init{
        panel=JamTop{
            content:bind content
            }
        setSize();
        }
    override public function getJComponent():JComponent{
        return panel.getJComponent();
        }
    override public function highlight(s:String):Boolean{
        return panel.highlight(s);
        }
    override public function gather():DataTree{
        var me:DataTree=DataTree{ name:"Sizer" };
        insert content.gather() into me.node("content").children;
        return me;
        }
    }
